//
//  CheckRecordListTableViewCell.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/11/2.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "CheckRecordListTableViewCell.h"
#import "LoginStatuesModel.h"
#import "UILabel+NSAttributeString.h"
@implementation CheckRecordListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.SureStatue.layer.cornerRadius=2.0;
    
    self.SureStatue.layer.masksToBounds=YES;
    
    self.ChangeStatue.layer.cornerRadius=2.0;
    
    self.ChangeStatue.layer.masksToBounds=YES;
    
    // Initialization code
    self.addressLabel.numberOfLines = 0;
    self.MarkImageView.hidden = YES;
    self.MarkLabel.hidden = YES;
}


-(void)setIsClick:(BOOL)isClick
{
    _isClick=isClick;
    
    if (self.isClick) {
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }else{
        self.accessoryType=UITableViewCellAccessoryNone;
    }
    
}

-(void)setDeleStatue:(BOOL)deleStatue
{
    _deleStatue=deleStatue;
    
    if (deleStatue) {
        
        self.editImageView.hidden=NO;
        
        self.accessoryType=UITableViewCellAccessoryNone;
        
    }else{
        
        self.editImageView.hidden=YES;
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        
    }
    
}

-(void)setRecordStatue:(CheckRecordData *)RecordStatue
{
    _RecordStatue=RecordStatue;
 
    if ([LoginStatuesModel getUserType]==1) {
        //商户
        self.CheckNameLabel.text=RecordStatue.subjectName;
        
    }else{
        
        if (self.otherSeeShop!=0) {
            //其他角色看商户，也不需要商户名
            self.CheckNameLabel.text=RecordStatue.subjectName;
        }else{
            
            self.CheckNameLabel.attributedText=[self.CheckNameLabel appShopName:RecordStatue.resultName andCheckList:RecordStatue.subjectName];
        }

    }
    
    if (RecordStatue.confirmState==1) {
  
        self.SureStatue.text=@"已确认";
        
        self.SureStatue.backgroundColor=kColorRGB(0xface48);
        
    }else{
        
        self.SureStatue.text=@"未确认";
        
        self.SureStatue.backgroundColor=kColorRGB(0xcccccc);
        
    }
    
    if (RecordStatue.rectifyState==1) {
        
        self.ChangeStatue.text=@"已整改";
        
        self.ChangeStatue.backgroundColor=kColorRGB(0x83d056);
        
    }else{
        
        self.ChangeStatue.text=@"未整改";
        
        self.ChangeStatue.backgroundColor=kColorRGB(0xcccccc);
    }
    
    
    self.MarkLabel.text=RecordStatue.resultGraded;

    self.CheckTimeLabel.text=RecordStatue.checkDate;
        
    self.CheckManLabel.text=[NSString stringWithFormat:@"%@",RecordStatue.staffName];
    self.addressLabel.text = [NSString stringWithFormat:@"%@",RecordStatue.address];
    
    if ([RecordStatue.resultGraded isEqualToString:@"A级"]) {
        
        self.MarkImageView.image=[UIImage imageNamed:@"MarksA"];
        
        self.MarkLabel.textColor=kColorRGB(0x58be8b);
        
    }else if ([RecordStatue.resultGraded isEqualToString:@"B级"])
    {
          self.MarkImageView.image=[UIImage imageNamed:@"MarksB"];
        
        self.MarkLabel.textColor=kColorRGB(0xf9cd55);
        
    }else if ([RecordStatue.resultGraded isEqualToString:@"C级"])
    {
          self.MarkImageView.image=[UIImage imageNamed:@"MarksC"];
        
        self.MarkLabel.textColor=kColorRGB(0xf7707a);
        
    }else{

          self.MarkImageView.image=[UIImage imageNamed:@"MarksD"];
        
        self.MarkLabel.textColor=kColorRGB(0xcccccc);
        
//         self.MarkLabel.text=@"不予评级";
        
    }
    
    
    if (self.deleStatue) {
  
        if (RecordStatue.Select) {
            
            self.editImageView.image=[UIImage imageNamed:@"Select"];
            
        }else{
            
            self.editImageView.image=[UIImage imageNamed:@"UnSelect"];
        }

    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
